/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright @ Huawei Technologies Co., Ltd. 2022-2022. ALL rights reserved.
 * Description: Header file for hpmm persistent memory.
 */

#ifndef _LINUX_HPMM_COMMON_H
#define _LINUX_HPMM_COMMON_H

#include <linux/mm.h>
#include <linux/hpmm.h>
#include <linux/types.h>

struct hpmm_driver {
	/* Indicates the type of hpmm_driver */
	int type;
	/* Indicates the name of hpmm_driver */
	char *name;
	/* Indicates the list where hpmm_driver is located. if the driver has been initialized. */
	struct list_head list;
	/* initializ the driver and the node */
	int (*create)(struct hpmm_device *hpmm_dev, struct hpmm_mem_info *mem_info);
	/* release the driver and resource */
	void (*destroy)(struct hpmm_device *hpmm_dev);
	/* clear the bbu memory area */
	int (*clear)(struct hpmm_device *hpmm_dev, struct hpmm_mem_info *mem_info);
	/* recover the bbu memory and do the rmap */
	int (*recover)(struct hpmm_device *hpmm_dev, struct hpmm_mem_info *mem_info);
	/* Establish a linear mapping between bbu memory and user space */
	int (*linear_memory_mapping)(struct hpmm_device *hpmm_dev, struct hpmm_mem_info *mem_info);
	/* Querying UCE records in the bbu memory */
	int (*query_uce)(struct hpmm_uce_records *records);
	/* Clear UCE records in the bbu memory */
	int (*clear_uce)(struct hpmm_uce_records *records);
};

void hpmm_register_memory_driver(struct hpmm_driver *driver);
void hpmm_unregister_memory_driver(struct hpmm_driver *driver);

#endif /* _LINUX_HPMM_COMMON_H */
